#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMdiSubWindow>
#include "textedit.h"
#include <QPrintPreviewDialog>
#include <QActionGroup>
#include <QSignalMapper>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_actionNew_triggered();
    void setDocActionStatus(bool b);
    void on_actionOpen_triggered();
    void on_actionSave_triggered();
    void on_actionSaveAs_triggered();
    void on_actionPrint_triggered();
    void on_actionPrintSee_triggered();
    void paintPreview(QPrinter* printer);
    void on_actionUndo_triggered();
    void on_actionRedo_triggered();
    void on_actionCut_triggered();
    void on_actionCopy_triggered();
    void on_actionPaste_triggered();
    void on_actionExit_triggered();
    void on_actionClose_triggered();
    void on_actionCloseAll_triggered();
    void on_actionTile_triggered();
    void on_actionCascade_triggered();
    void on_actionNext_triggered();
    void on_actionPrevious_triggered();
    void addSubWindowAction();                  //添加子窗体对应action
    void setActiveSubWindow(QWidget* widget);

    void on_actionColors_triggered();

    void on_actionBold_triggered(bool checked);

    void on_actionItalic_triggered(bool checked);

    void on_actionUnderLine_triggered(bool checked);

    void on_actionLeft_triggered();

    void on_actionCenter_triggered();

    void on_actionRight_triggered();

    void on_actionJustify_triggered();

    void on_comboBox_activated(int index);

    void on_fontComboBox_activated(const QString &arg1);

    void on_comboBoxSize_activated(const QString &arg1);

protected:
    void closeEvent(QCloseEvent* event) override;

private:
    void init();
    void initFontSize();
    void initScrollBar();
    void initWindowsAction();
    TextEdit* activateSubWindow();
    void initDocAction();
    QMdiSubWindow* findSubWindow(const QString& fileName);

private:
    Ui::MainWindow *ui;
    QActionGroup* group;          //操作组
    QSignalMapper* mapper;        //信号映射器
};
#endif // MAINWINDOW_H
